﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Threading.Tasks;

namespace Sino.CapacityCloud.Services
{

    public class RandomPasswordService
        : IRandomPasswordService
    {

        public async Task<string> GenerateRandomPasswordAsync(int length = 8)
        {
            //var randpwd = "";
            //var rand = new Random((int)DateTime.Now.Ticks);
            //for (var i = 0; i < length; i++)
            //{
            //    randpwd += (char)(rand.Next(33, 126));
            //}
            var randpwd = RandomPassword.Generate(length);
            return await Task.FromResult(randpwd);
        }

    }

}